#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
#include<stdlib.h>
#include<string.h>



char* compressString(char* S) {
    int len = string(len);
    char* tile = (char*)malloc((sizeof(char)* len * 2) + 2);
    char* ret = tile;
    char* fast = S + 1;
    char* det = S;
    while (*det)
    {
        int sum = 1;
        if (*fast == *det)
        {
            *tile++ = *det;
            while (*fast == *det)
            {
                sum++;
                fast++;
            }
            if (sum >= 10 && sum < 100)
            {
                *tile++ = sum / 10 + '0';
                *tile++ = sum % 10 + '0';

            }
            else if (sum >= 100 && sum < 1000)
            {
                *tile++ = sum / 100 + '0';
                *tile++ = sum % 100 / 10 + '0';
                *tile++ = sum % 10 + '0';
            }
            else if (sum >= 1000 && sum < 10000)
            {
                *tile++ = sum / 1000 + '0';
                *tile++ = sum % 1000 / 100 + '0';
                *tile++ = sum % 100 / 10 + '0';
                *tile++ = sum % 10 + '0';
            }
            else if (sum >= 10000 && sum < 100000)
            {
                *tile++ = sum / 10000 + '0';
                *tile++ = sum % 10000 / 1000 + '0';
                *tile++ = sum % 1000 / 100 + '0';
                *tile++ = sum % 100 / 10 + '0';
                *tile++ = sum % 10 + '0';
            }
            else
            {
                *tile++ = sum + '0';
            }
            det = fast;
            fast = det + 1;
        }
        else
        {
            *tile++ = *det++;
            *tile++ = '1';
            if (*fast)
                fast++;
        }

    }
    *tile = '\0';
    if (strlen(ret) >= strlen(S))
        return S;
    return ret;
}
int main()
{
    char s[] = "xvvvvvvvvvvvvvvvuuummmmmmmbbbbbbbbbbbbbaaaassssssssaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbaa";
    char* ret = compressString(s);
    puts(ret);
	return 0;
}